import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/component/list/table_view.dart';
import 'package:leader_help/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class AreaCompetePage extends GetView<AreaCompeteController> {
  const AreaCompetePage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return TableView(data: controller.state.list);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AreaCompeteController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(
            context,
            title: '区域竞争',
            bottom: PreferredSize(
              child: Container(
                height: 36.r,
                color: ColorsUtil.bg,
                child: TabBar(
                    controller: controller.state.tabCtrl,
                    padding: EdgeInsets.zero,
                    isScrollable: true,
                    indicatorColor: Colors.red[400],
                    indicatorSize: TabBarIndicatorSize.label,
                    labelColor: ColorsUtil.red,
                    unselectedLabelColor: ColorsUtil.title,
                    labelStyle:
                        TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold),
                    unselectedLabelStyle: TextStyle(fontSize: 14.sp),
                    tabs: controller.state.tabTitles
                        .asMap()
                        .map(
                          (key, value) => MapEntry(
                            key,
                            Tab(
                              text: value,
                              height: 30.r,
                            ),
                          ),
                        )
                        .values
                        .toList()),
              ),
              preferredSize: Size.fromHeight(36.r),
            ),
          ),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
